package test.yzx.pproject.act1;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.DecelerateInterpolator;
import android.widget.LinearLayout;
import android.widget.Toast;

import com.transitionseverywhere.ChangeBounds;
import com.transitionseverywhere.Transition;
import com.transitionseverywhere.TransitionManager;

import test.yzx.pproject.R;

/**
 * Created by yangzhongxu on 16/11/20
 */
public class Transition2Activity extends AppCompatActivity {


    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.transition2);


        getWindow().getDecorView().postDelayed(new Runnable() {
            @Override
            public void run() {
                final ChangeBounds cb = new ChangeBounds();
                cb.setDuration(800);
                cb.addListener(new Transition.TransitionListener() {
                    public void onTransitionStart(Transition transition) {
                    }
                    public void onTransitionEnd(Transition transition) {
                        Toast.makeText(Transition2Activity.this, "over", Toast.LENGTH_SHORT).show();
                    }
                    public void onTransitionCancel(Transition transition) {
                    }
                    public void onTransitionPause(Transition transition) {
                    }
                    public void onTransitionResume(Transition transition) {
                    }
                });
                cb.setInterpolator(new DecelerateInterpolator(0.8f));
                TransitionManager.beginDelayedTransition((ViewGroup) findViewById(R.id.container), cb);

                View view = findViewById(R.id.view);
                LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) view.getLayoutParams();
                lp.height = 0;
                view.requestLayout();
            }
        },1000);



    }



}
